<?php
namespace app\admin\controller;
use app\admin\model\LoginModel;
use think\Controller;

class Login extends  Controller
{
       public  function  login()
       {
           if (request()->isPost()) {
               $a = input('username');
               $p = input('password');
               $log = new LoginModel();
               $result = $log->login($a, $p);
               if ($result == 1) {
                   echo "<script>alert('用户名或密码错误');</script>";
               }else if ($result == 2){
                   $this->redirect('user/ulist');
               }

           }
           return $this->fetch();
       }
    public function logout(){
        //清空 session
        \think\Session::clear();
        //跳转到登录页
        $this->redirect('login/login');
    }
}